package com.yzh.wanandroid.expand.view

import android.app.Activity
import android.view.View
import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.appcompat.widget.Toolbar
import androidx.drawerlayout.widget.DrawerLayout

fun DrawerLayout.initDrawerLayout(
    activity: Activity,
    toolbar: Toolbar
) {
    val mActionBarDrawerToggle = object : ActionBarDrawerToggle(
        activity,
        this, toolbar, 0, 0
    ) {
        override fun onDrawerOpened(drawerView: View) {
            super.onDrawerOpened(drawerView)
        }

        override fun onDrawerClosed(drawerView: View) {
            super.onDrawerClosed(drawerView)
        }
    }
    mActionBarDrawerToggle.syncState()
    mActionBarDrawerToggle.isDrawerIndicatorEnabled = true
    this.addDrawerListener(mActionBarDrawerToggle)
}